Skip to content

Commit

Permalink
Merge pull request #399 from Nxer/main
Browse files Browse the repository at this point in the history
sync from main
  • Loading branch information
Nxer committed Apr 14, 2024
2 parents e42e171 + 4f93720 commit d89d82a
Show file tree
Hide file tree
Showing 10 changed files with 1,752 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class Sound extends PositionedSoundRecord {

public Sound(ResourceLocation soundResource, float volume, float pitch, boolean repeat, float xPosition,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package com.Nxer.TwistSpaceTechnology.common.Entity;

import java.util.Iterator;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import com.Nxer.TwistSpaceTechnology.client.Audio.Sound;
import com.Nxer.TwistSpaceTechnology.config.Config;
import com.Nxer.TwistSpaceTechnology.common.block.blockClass.BlockPowerChair;

public class EntityMountableBlock extends Entity {

Expand All @@ -24,7 +18,6 @@ public class EntityMountableBlock extends Entity {
public int orgBlockPosZ;
public Block orgBlock;
public EntityPlayer player;
public Sound sound;

public EntityMountableBlock(World worldIn) {
super(worldIn);
Expand All @@ -46,50 +39,25 @@ public EntityMountableBlock(World world, EntityPlayer player, int x, int y, int
this.orgBlockPosZ = z;
this.orgBlock = world.getBlock(x, y, z);
this.setPosition(mountingX, mountingY, mountingZ);
if (Config.Enable_PowerChairBGM) {
this.sound = new Sound(BGM, 0.4f, 1.0f, true, x, y, z);
}
}

public static boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, float hitX,
float hitY, float hitZ) {
if (!world.isRemote) {
List listEMB = world.getEntitiesWithinAABB(
EntityMountableBlock.class,
AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 1.0D, (double) z + 1.0D)
.expand(1.0D, 1.0D, 1.0D));
Iterator i = listEMB.iterator();
EntityMountableBlock mounting;

do {
if (!i.hasNext()) {
double mountingX = (double) x + hitX;
double mountingY = (double) y + hitY;
double mountingZ = (double) z + hitZ;

EntityMountableBlock entity = new EntityMountableBlock(
world,
player,
x,
y,
z,
mountingX,
mountingY,
mountingZ);
world.spawnEntityInWorld(entity);
entity.interact(player);
if (Config.Enable_PowerChairBGM) {
Minecraft.getMinecraft()
.getSoundHandler()
.playSound(entity.sound);
}
return true;
}

mounting = (EntityMountableBlock) i.next();
} while (mounting.orgBlockPosX != x || mounting.orgBlockPosY != y || mounting.orgBlockPosZ != z);

mounting.interact(player);
double mountingX = (double) x + hitX;
double mountingY = (double) y + hitY;
double mountingZ = (double) z + hitZ;
EntityMountableBlock entity = new EntityMountableBlock(
world,
player,
x,
y,
z,
mountingX,
mountingY,
mountingZ);
world.spawnEntityInWorld(entity);
entity.interact(player);
return true;
} else {
return false;
Expand All @@ -116,13 +84,10 @@ public void onEntityUpdate() {
return;
} else {
this.setDead();
if (this.sound != null) {
Minecraft.getMinecraft()
.getSoundHandler()
.stopSound(this.sound);
if (worldObj.isRemote) {
BlockPowerChair.stopPlaySound();
}
}

++this.ticksExisted;
this.worldObj.theProfiler.endSection();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import com.Nxer.TwistSpaceTechnology.client.Audio.Sound;
import com.Nxer.TwistSpaceTechnology.client.GTCMCreativeTabs;
import com.Nxer.TwistSpaceTechnology.common.Entity.EntityMountableBlock;
import com.Nxer.TwistSpaceTechnology.common.tile.TilePowerChair;
import com.Nxer.TwistSpaceTechnology.config.Config;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockPowerChair extends Block {

public static Sound sound;

public BlockPowerChair() {
super(Material.iron);
this.setResistance(20f);
Expand Down Expand Up @@ -84,37 +90,54 @@ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase p
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7,
float par8, float par9) {

TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TilePowerChair) {
int metadata = world.getBlockMetadata(x, y, z);
metadata %= 4;
if (metadata == 0) {
player.rotationYaw = 90.0F;

return EntityMountableBlock.onBlockActivated(world, x, y, z, player, 0.5F, 0.68F, 0.5F);
}

if (metadata == 1) {
player.rotationYaw = -90.0F;

return EntityMountableBlock.onBlockActivated(world, x, y, z, player, 0.5F, 0.68F, 0.5F);
}

if (metadata == 2) {
player.rotationYaw = 180.0F;

return EntityMountableBlock.onBlockActivated(world, x, y, z, player, 0.5F, 0.68F, 0.5F);
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TilePowerChair) {
int metadata = world.getBlockMetadata(x, y, z);
metadata %= 4;
switch (metadata) {
case 0 -> {
player.rotationYaw = 90.0F;
EntityMountableBlock.onBlockActivated(world, x, y, z, player, 0.5F, 0.68F, 0.5F);
}
case 1 -> {
player.rotationYaw = -90.0F;
EntityMountableBlock.onBlockActivated(world, x, y, z, player, 0.5F, 0.68F, 0.5F);
}
case 2 -> {
player.rotationYaw = 180.0F;
EntityMountableBlock.onBlockActivated(world, x, y, z, player, 0.5F, 0.68F, 0.5F);
}
case 3 -> {
player.rotationYaw = 0.0F;
EntityMountableBlock.onBlockActivated(world, x, y, z, player, 0.5F, 0.68F, 0.5F);
}
}
}
} else {
PlaySound(x, y, z);
return false;
}
return false;
}

if (metadata == 3) {
player.rotationYaw = 0.0F;

return EntityMountableBlock.onBlockActivated(world, x, y, z, player, 0.5F, 0.68F, 0.5F);
} else return false;
@SideOnly(Side.CLIENT)
private void PlaySound(int x, int y, int z) {
if (Config.Enable_PowerChairBGM) {
sound = new Sound(new ResourceLocation("gtnhcommunitymod:PowerChair"), 0.4f, 1.0f, true, x, y, z);
Minecraft.getMinecraft()
.getSoundHandler()
.playSound(sound);
}
}

return false;
@SideOnly(Side.CLIENT)
public static void stopPlaySound() {
if (Config.Enable_PowerChairBGM) {
Minecraft.getMinecraft()
.getSoundHandler()
.stopSound(sound);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,19 @@ public boolean supportsSingleRecipeLocking() {
return false;
}

private static final FluidStack HONEY = Materials.Honey.getFluid(1);
private static final FluidStack UUM = Materials.UUMatter.getFluid(1);
private static FluidStack HONEY;
private static FluidStack UUM;

@Override
public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
super.onFirstTick(aBaseMetaTileEntity);
if (HONEY == null) {
HONEY = Materials.Honey.getFluid(1);
}
if (UUM == null) {
UUM = Materials.UUMatter.getFluid(1);
}
}

@Override
@NotNull
Expand All @@ -105,7 +116,7 @@ public CheckRecipeResult checkProcessing() {
long honeyAmount = 0;
long uuAmount = 0;
for (FluidStack fluidStack : inputFluid) {
if (fluidStack == null || fluidStack.amount > 1) continue;
if (fluidStack == null || fluidStack.amount < 1) continue;
if (!honeyEnough && fluidStack.isFluidEqual(HONEY)) {
honeyStacks.add(fluidStack);
honeyAmount += fluidStack.amount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jetbrains.annotations.NotNull;

import com.Nxer.TwistSpaceTechnology.common.machine.multiMachineClasses.processingLogics.GTCM_ProcessingLogic;
import com.Nxer.TwistSpaceTechnology.config.Config;
import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;

Expand Down Expand Up @@ -421,6 +422,14 @@ public boolean explodesOnComponentBreak(ItemStack aStack) {
return false;
}

/**
* no longer afraid of rain
*/
@Override
public boolean willExplodeInRain() {
return false;
}

@Override
public boolean supportsVoidProtection() {
return true;
Expand All @@ -436,6 +445,12 @@ public boolean supportsBatchMode() {
return true;
}

@Override
public boolean getDefaultBatchMode() {
if (!supportsBatchMode()) return false;
return Config.DEFAULT_BATCH_MODE;
}

@Override
public boolean supportsSingleRecipeLocking() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class Config {

// region General
public static int MAX_PARALLEL_LIMIT = Integer.MAX_VALUE;
public static boolean DEFAULT_BATCH_MODE = false;

// endregion

Expand Down Expand Up @@ -358,6 +359,7 @@ public static void synchronizeConfiguration(File configFile) {

// region General
MAX_PARALLEL_LIMIT = configuration.getInt("MAX_PARALLEL_LIMIT", GENERAL, MAX_PARALLEL_LIMIT, 1, Integer.MAX_VALUE, "Max parallel limit of normal machines.");
DEFAULT_BATCH_MODE = configuration.getBoolean("DEFAULT_BATCH_MODE", GENERAL, DEFAULT_BATCH_MODE, "Default Batch mode state of machine when placed. True is auto enable Batch mode.");
// endregion

// region Recipe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@ public void loadRecipes() {
GT_Values.RA
.stdBuilder()
.metadata(RESEARCH_ITEM, Machine_Multi_Computer.get(1))
.metadata(RESEARCH_TIME, 114514 * 20 * 100)
.metadata(RESEARCH_TIME, 114514 * 20)
.itemInputs(
Machine_Multi_Computer.get(64),
Machine_Multi_Computer.get(64),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/gtnhcommunitymod/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ TST_DSPReceiver.modeMsg.1=Mode: Photon Collection
DSPName=§9Dyson Sphere Program
NEI.DSP_ReceiverRecipes.specialValue.pre=Equivalent EU:
ExampleRecipe.CriticalPhoton=Example recipe: 2147483647 EU per Critical Photon.
MiracleTop.modeMsg.0=Mode: Circuit Assembler
MiracleTop.modeMsg.0=Mode: Miracle Top (Circuit Assembler)
MiracleTop.modeMsg.1=Mode: Gravitation Inversion
MetaItem01.14.name=Antimatter
MetaItem01.16.name=Antimatter Fuel Rod
Expand Down
Loading

0 comments on commit d89d82a

Please sign in to comment.