Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pWn3d1337 committed Nov 12, 2017
1 parent 8a0e122 commit 7de892b
Show file tree
Hide file tree
Showing 127 changed files with 288 additions and 2,318 deletions.
5 changes: 5 additions & 0 deletions src/main/java/techguns/TGPackets.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
Expand Down Expand Up @@ -45,6 +46,10 @@ public static EntityPlayer getPlayerFromContext(MessageContext ctx){
return thePlayer;
}

public static TargetPoint targetPointAroundBlockPos(int dimension, BlockPos pos, double distance){
return new TargetPoint(dimension, pos.getX()+0.5d, pos.getY()+0.5d, pos.getZ()+0.5d, distance);
}

public static TargetPoint targetPointAroundEnt(Entity ent, double distance){
return new TargetPoint(ent.dimension, ent.posX, ent.posY, ent.posZ, distance);
}
Expand Down
84 changes: 64 additions & 20 deletions src/main/java/techguns/blocks/BlockTGDoor3x3.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class BlockTGDoor3x3<T extends Enum<T> & IStringSerializable> extends Gen
protected static final AxisAlignedBB BB_X_openTop = new AxisAlignedBB(0,1-size2,size,1,1,1-size);
protected static final AxisAlignedBB BB_Z_openTop = new AxisAlignedBB(size,1-size2,0,1-size,1,1);

protected static final AxisAlignedBB BB_X_openBottom = new AxisAlignedBB(0,0,size,1,size2,1-size);
protected static final AxisAlignedBB BB_Z_openBottom = new AxisAlignedBB(size,0,0,1-size,size2,1);

protected static final AxisAlignedBB BB_Z_openLeft = new AxisAlignedBB(size, 0, 0, 1-size, 1, size2);
protected static final AxisAlignedBB BB_Z_openRight = new AxisAlignedBB(size, 0, 1-size2, 1-size, 1, 1);

Expand Down Expand Up @@ -197,37 +200,78 @@ public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, Block
public static AxisAlignedBB NO_COLLIDE=new AxisAlignedBB(0, 0, 0, 0, 0, 0);
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {

if(!isStateOpen(state)) {
return getBBforPlane(state);
} else {
BlockPos master = findMaster(source, pos, state);
if(state.getValue(MASTER) || master.getY()>= pos.getY()) {

if(!state.getValue(ZPLANE)) {
if(pos.getX()<master.getX()) {
return BB_X_openLeft;
} else if ( pos.getX()>master.getX()) {
return BB_X_openRight;
}
} else {
if(pos.getZ()<master.getZ()) {
return BB_Z_openLeft;
} else if ( pos.getZ()>master.getZ()) {
return BB_Z_openRight;
}
IBlockState masterstate=getActualState(source.getBlockState(master), source, master);
EnumDoorType type = masterstate.getValue(TYPE);

if(type==EnumDoorType.HANGAR_UP) {
return getOpenBBforTypeHangarUp(state, pos, master);
} else if (type==EnumDoorType.HANGAR_DOWN) {
return getOpenBBforTypeHangarDown(state, pos, master);
} else {
return getOpenBBforTypeMetal(state, pos, master);
}
}
}

protected AxisAlignedBB getOpenBBforTypeMetal(IBlockState state, BlockPos pos, BlockPos master) {
if(state.getValue(MASTER) || master.getY()>= pos.getY()) {

if(!state.getValue(ZPLANE)) {
if(pos.getX()<master.getX()) {
return BB_X_openLeft;
} else if ( pos.getX()>master.getX()) {
return BB_X_openRight;
}
return NO_COLLIDE;
} else {
if(!state.getValue(ZPLANE)) {
return BB_X_openTop;
} else {
return BB_Z_openTop;
if(pos.getZ()<master.getZ()) {
return BB_Z_openLeft;
} else if ( pos.getZ()>master.getZ()) {
return BB_Z_openRight;
}
//return getBBforPlane(state);
}
return NO_COLLIDE;
} else {
if(!state.getValue(ZPLANE)) {
return BB_X_openTop;
} else {
return BB_Z_openTop;
}
//return getBBforPlane(state);
}
}

protected AxisAlignedBB getOpenBBforTypeHangarUp(IBlockState state, BlockPos pos, BlockPos master) {
if(state.getValue(MASTER) || master.getY()>= pos.getY()) {
return NO_COLLIDE;
} else {
if(!state.getValue(ZPLANE)) {
return BB_X_openTop;
} else {
return BB_Z_openTop;
}
//return getBBforPlane(state);
}
}

protected AxisAlignedBB getOpenBBforTypeHangarDown(IBlockState state, BlockPos pos, BlockPos master) {
if(state.getValue(MASTER) || master.getY()<= pos.getY()) {
return NO_COLLIDE;
} else {
if(!state.getValue(ZPLANE)) {
return BB_X_openBottom;
} else {
return BB_Z_openBottom;
}
//return getBBforPlane(state);
}
}


protected AxisAlignedBB getBBforPlane(IBlockState state) {
if(state.getValue(ZPLANE)) {
return BB_X;
Expand Down
33 changes: 31 additions & 2 deletions src/main/java/techguns/blocks/machines/BlockExplosiveCharge.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
Expand All @@ -33,9 +34,27 @@ public class BlockExplosiveCharge<T extends Enum<T> & IStringSerializable & IMac
public BlockExplosiveCharge(String name, Class<T> clazz) {
super(name, clazz);
this.blockStateOverride = new BlockStateContainer.Builder(this).add(FACING).add(MACHINE_TYPE).add(ARMED).build();
this.setDefaultState(this.getBlockState().getBaseState());
this.setDefaultState(this.getBlockState().getBaseState().withProperty(ARMED, false));
}

protected static final AxisAlignedBB[] boundingBoxes = {
//D,U,N,S,W,E
new AxisAlignedBB(2/16d, 0, 2/16d, 14/16d, 5/16d, 14/16d),
new AxisAlignedBB(2/16d, 11/16d, 2/16d, 14/16d, 1, 14/16d),

new AxisAlignedBB(2/16d, 2/16d, 0, 14/16d, 14/16d, 5/16d),
new AxisAlignedBB(2/16d, 2/16d, 11/16d, 14/16d, 14/16d, 1),

new AxisAlignedBB(0, 2/16d, 2/16d, 5/16d, 14/16d, 14/16d),
new AxisAlignedBB(11/16d, 2/16d, 2/16d, 1, 14/16d, 14/16d)
};

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
EnumFacing facing = state.getValue(FACING);
return boundingBoxes[facing.getIndex()];
}

@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(FACING).getIndex() << 1 | state.getValue(MACHINE_TYPE).getIndex();
Expand Down Expand Up @@ -68,7 +87,7 @@ public boolean isOpaqueCube(IBlockState state) {
return false;
}

/**
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
Expand All @@ -87,6 +106,16 @@ public void registerItemBlockModels() {
}
}

@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
super.neighborChanged(state, worldIn, pos, blockIn, fromPos);

if (worldIn.isAirBlock(pos.offset(state.getValue(FACING)))){
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
}

@Override
public IBlockState withRotation(IBlockState state, Rotation rot) {
EnumFacing facing = state.getValue(FACING);
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/techguns/items/guns/GenericGunCharge.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,7 @@ public void onPlayerStoppedUsing(ItemStack item, World world, EntityLivingBase e

if (this.hasChargedFireAnim) {

//world.playSoundAtEntity(player, firesound, 1.0F, 1.0F);
SoundUtil.playSoundOnEntityGunPosition(world, player, firesound, SOUND_DISTANCE, 1.0f, false, false,true, TGSoundCategory.GUN_FIRE);

if (!(rechamberSound==null)) {
//world.playSoundAtEntity(player, rechamberSound, 1.0F, 1.0F);
SoundUtil.playSoundOnEntityGunPosition(world, player, rechamberSound, 1.0f, 1.0f, false, false,true, TGSoundCategory.GUN_FIRE);
}
this.playChargedFiresound(item, world, player, f);

}

Expand Down Expand Up @@ -270,6 +264,15 @@ public void onPlayerStoppedUsing(ItemStack item, World world, EntityLivingBase e
}
}

protected void playChargedFiresound(ItemStack item, World world, EntityPlayer player, float chargeProgress) {

SoundUtil.playSoundOnEntityGunPosition(world, player, firesound, SOUND_DISTANCE, 1.0f, false, false,true, TGSoundCategory.GUN_FIRE);

if (!(rechamberSound==null)) {
SoundUtil.playSoundOnEntityGunPosition(world, player, rechamberSound, 1.0f, 1.0f, false, false,true, TGSoundCategory.GUN_FIRE);
}
}

@Override
public int getMaxItemUseDuration(ItemStack stack) {
return 288000;
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/techguns/recipes/Recipewriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import techguns.blocks.BlockTGLadder;
import techguns.blocks.EnumLadderType;
import techguns.blocks.TGMetalPanelType;
import techguns.blocks.machines.EnumExplosiveChargeType;
import techguns.blocks.machines.EnumMachineType;
import techguns.blocks.machines.EnumMultiBlockMachineType;
import techguns.blocks.machines.EnumSimpleMachineType;
Expand Down Expand Up @@ -302,6 +303,9 @@ public static void registerItemRecipes(){
RecipeJsonConverter.addShapedRecipe(new ItemStack(TGBlocks.METAL_STAIRS,6,15), "b ", "bb ", "bbb", 'b', new ItemStack(TGBlocks.METAL_PANEL,1,TGMetalPanelType.STEELFRAME_DARK.ordinal()));
RecipeJsonConverter.addShapelessRecipe(new ItemStack(TGBlocks.METAL_PANEL,1,TGMetalPanelType.STEELFRAME_DARK.ordinal()), new ItemStack(TGBlocks.METAL_STAIRS,1,15));

RecipeJsonConverter.addShapedRecipe(new ItemStack(TGBlocks.EXPLOSIVE_CHARGE,8,TGBlocks.EXPLOSIVE_CHARGE.getMetaFromState(TGBlocks.EXPLOSIVE_CHARGE.getDefaultState())), "rtr","tct","rtr", 'r', "itemRubber", 't', Blocks.TNT, 'c', "circuitBasic");
RecipeJsonConverter.addShapedRecipe(new ItemStack(TGBlocks.EXPLOSIVE_CHARGE,4,TGBlocks.EXPLOSIVE_CHARGE.getMetaFromState(TGBlocks.EXPLOSIVE_CHARGE.getDefaultState().withProperty(TGBlocks.EXPLOSIVE_CHARGE.MACHINE_TYPE, EnumExplosiveChargeType.ADVANCED))), "rtr","tct","rtr", 'r', "sheetPlastic", 't', TGItems.TGX, 'c', "circuitBasic");


String[] plateTypes = {"plateIron", "plateTin"};
Arrays.stream(plateTypes).forEach(p -> {
Expand Down Expand Up @@ -531,9 +535,7 @@ public static void notyetimplemented() {
RecipeJsonConverter.addShapedRecipe(newStack(oreDrillLargeObsidianSteel,1),"d d"," d ", 'd', TGItems.oreDrillMediumObsidianSteel));
RecipeJsonConverter.addShapedRecipe(newStack(oreDrillLargeCarbon,1),"d d"," d ", 'd', TGItems.oreDrillMediumCarbon));
RecipeJsonConverter.addShapedRecipe(new ItemStack(TGBlocks.basicMachine,8,6), "rtr","tct","rtr", 'r', "itemRubber", 't', Blocks.tnt, 'c', "circuitBasic"));
RecipeJsonConverter.addShapedRecipe(new ItemStack(TGBlocks.basicMachine,4,8), "rtr","tct","rtr", 'r', "sheetPlastic", 't', TGItems.tgx, 'c', "circuitBasic"));
RecipeJsonConverter.addShapedRecipe(new ItemStack(TGItems.oreClusterScanner,1), "g g", "pcp","pep", 'g', "wireGold", 'p', "plateSteel", 'c', "circuitElite", 'e', TGItems.energyCell));
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/techguns/tileentities/ExplosiveChargeTileEnt.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.BlockEvent;
import techguns.TGConfig;
import techguns.TGPackets;
import techguns.TGSounds;
import techguns.Techguns;
import techguns.blocks.machines.BlockExplosiveCharge;
import techguns.packets.PacketSpawnParticle;

public class ExplosiveChargeTileEnt extends BasicOwnedTileEnt implements ITickable {

Expand Down Expand Up @@ -150,17 +152,14 @@ protected boolean explodeBlock(MutableBlockPos coords){
MinecraftForge.EVENT_BUS.post(breakEvent);

if (!breakEvent.isCanceled()){
if (!this.world.isRemote){
block.dropBlockAsItem(world,coords, bs,0);
world.setBlockToAir(coords);
} else {
//Techguns.proxy.spawnParticle("Explosion", this.worldObj, coords.x+0.5D, coords.y+0.5D, coords.z+0.5D, 0, 0.025f, 0);
if (world.rand.nextFloat()>0.5f){
//TODO: Particles
//Techguns.proxy.spawnParticle("LargeSmoke", this.world, coords.getX()+0.25D+world.rand.nextDouble()*0.5D, coords.getY()+0.25D+world.rand.nextDouble()*0.5D, coords.getZ()+0.25D+world.rand.nextDouble()*0.5D, 0, 0.045f, 0);
//Techguns.proxy.spawnParticle("Explosion", this.world, coords.getX()+0.25D+world.rand.nextDouble()*0.5D, coords.getY()+0.25D+world.rand.nextDouble()*0.5D, coords.getZ()+0.25D+world.rand.nextDouble()*0.5D, 0, 0.045f, 0);
}

block.dropBlockAsItem(world,coords, bs,0);
world.setBlockToAir(coords);

if (world.rand.nextFloat()>0.5f){
TGPackets.network.sendToAllAround(new PacketSpawnParticle("MiningChargeBlockExplosion", coords.getX()+0.5d, coords.getY()+0.5d, coords.getZ()+0.5d), TGPackets.targetPointAroundBlockPos(this.world.provider.getDimension(),coords,50));
}

return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public AxisAlignedBB getRenderBoundingBox() {
EnumFacing left = multiblockDirection.rotateY();

BlockPos other = p.offset(multiblockDirection, 2).offset(left, 2).offset(EnumFacing.UP,2);
BlockPos first = p.offset(multiblockDirection.getOpposite(),1).offset(left.getOpposite(),1).offset(EnumFacing.DOWN,1);
BlockPos first = p.offset(multiblockDirection.getOpposite(),2).offset(left.getOpposite(),1).offset(EnumFacing.DOWN,1);
return new AxisAlignedBB(first,other);
} else {
return super.getRenderBoundingBox();
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/techguns/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -595,4 +595,6 @@ tile.techguns.metalpanel.7.name=Dark Scaffold
tile.techguns.stairs_metal.7.name=Steel Panel Stairs
tile.techguns.stairs_metal.15.name=Carbon Panel Stairs
tile.techguns.block_milk.name=Milk
fluid.milk=Milk
fluid.milk=Milk
tile.techguns.explosive_charge.0.name=Mining Charge
tile.techguns.explosive_charge.1.name=Advanced Mining Charge
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"parent": "block/block",
"textures": {
"0": "techguns:blocks/c4_charge",
"particle": "techguns:blocks/c4_charge"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"parent": "block/block",
"textures": {
"0": "techguns:blocks/c4_charge_armed",
"particle": "techguns:blocks/c4_charge_armed"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"parent": "block/block",
"ambientocclusion": false,
"textures": {
"0": "techguns:blocks/tnt_charge",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"parent": "block/block",
"ambientocclusion": false,
"textures": {
"0": "techguns:blocks/tnt_charge_armed",
Expand Down
39 changes: 38 additions & 1 deletion src/main/resources/assets/techguns/particles/fxlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,6 @@ HeliExplosion
HeliExplosionRing
HeliExplosionParts
}
}

FXLIST TFGTrail {
TFGTrailMainFlare
Expand Down Expand Up @@ -3475,3 +3474,41 @@ ParticlesStickToSystem = true
particlesMoveWithSystem = true
//Offset= -0.14 -0.10 0.42
}

MiningChargeExplosionFire {
Texture = techguns:textures/fx/fireblast.png
RenderType = ALPHA
Rows = 5
Columns = 5
Frames = 20
angle = 0 360
angleRate = -10 10
angleRateDamping = 0.85 0.88
Lifetime = 15 25
SystemLifetime = 1 1
Size = 1.5 2.5
SizeRate = 1.60 2.4
SizeRateDamping = 0.88 0.94
Alpha = 0.0 0
Alpha = 1.0 0.25
Alpha = 0 1.0
//Alpha = 1 1 0
Color = 255 255 255 0
Color = 255 255 255 1
ParticleCount = 3 4
InitialDelay = 0 0
SpawnDelay = 1 1
VelocityType = OUTWARD
Velocity1 = 0.4 1.5
Velocity2 = 0 0.75
VelocityDamping = 0.85 0.88
Gravity = 0.0
VolumeType = CYLINDER
Volume1 = 1.0
Volume2 = 0.75
}

FXLIST MiningChargeBlockExplosion {
MiningChargeExplosionFire
MediumExplosionSmoke
}
Loading

0 comments on commit 7de892b

Please sign in to comment.