Skip to content

Commit

Permalink
Rename instanceof variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-OOG-ah committed Sep 25, 2024
1 parent 3e6703e commit 9ff3409
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 55 deletions.
10 changes: 5 additions & 5 deletions src/main/java/binnie/botany/Botany.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,19 @@ public void onShearFlower(PlayerInteractEvent event) {
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null
&& event.entityPlayer.getHeldItem().getItem() == Items.shears) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower tef) {
tef.onShear();
if (tile instanceof TileEntityFlower tileFlower) {
tileFlower.onShear();
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
}
}

if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null
&& event.entityPlayer.getHeldItem().getItem() == Botany.pollen) {
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileEntityFlower tef) {
if (tile instanceof TileEntityFlower tileFlower) {
IFlower pollen = BotanyCore.getFlowerRoot().getMember(event.entityPlayer.getHeldItem());
if (pollen != null && tef.canMateWith(pollen)) {
tef.mateWith(pollen);
if (pollen != null && tileFlower.canMateWith(pollen)) {
tileFlower.mateWith(pollen);
if (!event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/binnie/botany/flower/BlockFlower.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase e
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlower f)) {
if (!(tile instanceof TileEntityFlower tileFlower)) {
return super.getIcon(world, x, y, z, side);
}

EnumFlowerStage stage = (f.getAge() == 0) ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER;
IFlowerType flower = f.getType();
int section = f.getRenderSection();
boolean flowered = f.isFlowered();
EnumFlowerStage stage = (tileFlower.getAge() == 0) ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER;
IFlowerType flower = tileFlower.getType();
int section = tileFlower.getRenderSection();
boolean flowered = tileFlower.isFlowered();
if (RendererBotany.pass == 0) {
return flower.getStem(stage, flowered, section);
}
Expand All @@ -128,11 +128,11 @@ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower f) {
if (tile instanceof TileEntityFlower tileFlower) {
if (RendererBotany.pass == 0) {
return f.getStemColour();
return tileFlower.getStemColour();
}
return (RendererBotany.pass == 1) ? f.getPrimaryColor() : f.getSecondaryColor();
return (RendererBotany.pass == 1) ? tileFlower.getPrimaryColor() : tileFlower.getSecondaryColor();
}
return 0xffffff;
}
Expand All @@ -151,13 +151,13 @@ public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
super.onNeighborBlockChange(world, x, y, z, block);
checkAndDropBlock(world, x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlower flower)) {
if (!(tile instanceof TileEntityFlower tileFlower)) {
return;
}

if (flower.getSection() == 0 && flower.getFlower() != null
&& flower.getFlower().getAge() > 0
&& flower.getFlower().getGenome().getPrimary().getType().getSections() > 1
if (tileFlower.getSection() == 0 && tileFlower.getFlower() != null
&& tileFlower.getFlower().getAge() > 0
&& tileFlower.getFlower().getGenome().getPrimary().getType().getSections() > 1
&& world.getBlock(x, y + 1, z) != Botany.flower) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/binnie/botany/gardening/Gardening.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ public static boolean plant(World world, int x, int y, int z, IFlower flower, Ga
return false;
}

TileEntity tileFlower = world.getTileEntity(x, y, z);
TileEntity below = world.getTileEntity(x, y - 1, z);
if (tileFlower instanceof TileEntityFlower tef) {
if (below instanceof TileEntityFlower tefB) {
tef.setSection(tefB.getSection());
final TileEntity tile = world.getTileEntity(x, y, z);
final TileEntity below = world.getTileEntity(x, y - 1, z);
if (tile instanceof TileEntityFlower tileFlower) {
if (below instanceof TileEntityFlower lowerFlower) {
tileFlower.setSection(lowerFlower.getSection());
} else {
tef.create(flower, owner);
tileFlower.create(flower, owner);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public void sendNBTToClient(String key, NBTTagCompound nbt) {

@Override
public boolean canInteractWith(EntityPlayer player) {
if (player instanceof EntityPlayerMP emp) {
if (!crafters.contains(emp)) {
crafters.add(emp);
if (player instanceof EntityPlayerMP playerMP) {
if (!crafters.contains(playerMP)) {
crafters.add(playerMP);
}
sentNBT.clear();
}
Expand Down Expand Up @@ -298,8 +298,8 @@ public void detectAndSendChanges() {

if (shouldSend) {
for (Object crafter : crafters) {
if (crafter instanceof EntityPlayerMP player) {
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), player);
if (crafter instanceof EntityPlayerMP playerMP) {
BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate(nbt.getValue()), playerMP);
}
}
sentThisTime.put(nbt.getKey(), nbt.getValue());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/binnie/core/genetics/Gene.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public IAllele getAllele() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Gene g)) {
if (!(obj instanceof Gene gene)) {
return false;
}

return allele == g.allele && chromosome.ordinal() == g.chromosome.ordinal() && root == g.root;
return allele == gene.allele && chromosome.ordinal() == gene.chromosome.ordinal() && root == gene.root;
}

public String getAlleleName() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/binnie/core/machines/BlockMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntity tileentity = world.getTileEntity(x, y, z);
if (!(tileentity instanceof TileEntityMachine entity)) {
if (!(tileentity instanceof TileEntityMachine machine)) {
return;
}

entity.onBlockDestroy();
machine.onBlockDestroy();
super.breakBlock(world, x, y, z, block, meta);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/binnie/core/machines/power/ProcessInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public ProcessInfo(IProcess process) {
processTime = 0;
energyPerTick = process.getEnergyPerTick();

if (process instanceof IProcessTimed time) {
currentProgress = time.getProgress();
processEnergy = time.getProcessEnergy();
processTime = time.getProcessLength();
if (process instanceof IProcessTimed processTimed) {
currentProgress = processTimed.getProgress();
processEnergy = processTimed.getProcessEnergy();
processTime = processTimed.getProcessLength();
} else {
currentProgress = process.isInProgress() ? 100.0f : 0.0f;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/binnie/core/nei/RecipeHandlerBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ protected boolean transferFluidTank(GuiRecipe<?> guiRecipe, int recipe, boolean

public void drawFluidTanks(int recipe) {
CachedRecipe cachedRecipe = this.arecipes.get(recipe);
if (cachedRecipe instanceof CachedBaseRecipe crecipe) {
if (crecipe.getFluidTanks() != null) {
for (PositionedFluidTank fluidTank : crecipe.getFluidTanks()) {
if (cachedRecipe instanceof CachedBaseRecipe baseRecipe) {
if (baseRecipe.getFluidTanks() != null) {
for (PositionedFluidTank fluidTank : baseRecipe.getFluidTanks()) {
fluidTank.draw();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b
float i = 0.0625f;
FenceType fenceType = new FenceType(0);
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityMetadata tem && block instanceof BlockMultiFence) {
fenceType = WoodManager.getFenceType(tem.getTileMetadata());
if (tile instanceof TileEntityMetadata tileMeta && block instanceof BlockMultiFence) {
fenceType = WoodManager.getFenceType(tileMeta.getTileMetadata());
}

boolean rendered;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/binnie/extratrees/carpentry/BlockDesign.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void onClick(PlayerInteractEvent event) {
int x = event.x;
int y = event.y;
int z = event.z;
if (!(world.getBlock(x, y, z) instanceof BlockDesign blockC)) {
if (!(world.getBlock(x, y, z) instanceof BlockDesign blockDesign)) {
return;
}

Expand All @@ -65,10 +65,10 @@ public void onClick(PlayerInteractEvent event) {
return;
}

DesignBlock block = blockC.getCarpentryBlock(world, x, y, z);
DesignBlock carpentryBlock = blockDesign.getCarpentryBlock(world, x, y, z);
TileEntityMetadata tile = (TileEntityMetadata) world.getTileEntity(x, y, z);
block.rotate(event.face, item, player, world, x, y, z);
int meta = block.getBlockMetadata(blockC.getDesignSystem());
carpentryBlock.rotate(event.face, item, player, world, x, y, z);
int meta = carpentryBlock.getBlockMetadata(blockDesign.getDesignSystem());
tile.setTileMetadata(meta, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public static void calculateLumbermillProducts() {
private static Collection<ItemStack> getRecipeResult(ItemStack output) {
List<ItemStack> list = new ArrayList<>();
for (IRecipe iRecipe : CraftingManager.getInstance().getRecipeList()) {
if (iRecipe instanceof ShapelessRecipes recipe) {
if (recipe.recipeItems.size() != 1 || !(recipe.recipeItems.get(0) instanceof ItemStack)) {
if (iRecipe instanceof ShapelessRecipes shapeless) {
if (shapeless.recipeItems.size() != 1 || !(shapeless.recipeItems.get(0) instanceof ItemStack)) {
continue;
}

ItemStack input = recipe.recipeItems.get(0);
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().isItemEqual(output)) {
ItemStack input = shapeless.recipeItems.get(0);
if (shapeless.getRecipeOutput() != null && shapeless.getRecipeOutput().isItemEqual(output)) {
list.add(input);
}
}
Expand All @@ -77,12 +77,12 @@ private static Collection<ItemStack> getRecipeResult(ItemStack output) {
}
}

if (iRecipe instanceof ShapelessOreRecipe shore) {
if (shore.getInput().size() != 1 || !(shore.getInput().get(0) instanceof ItemStack input)) {
if (iRecipe instanceof ShapelessOreRecipe shapelessOre) {
if (shapelessOre.getInput().size() != 1 || !(shapelessOre.getInput().get(0) instanceof ItemStack input)) {
continue;
}

if (shore.getRecipeOutput() == null || !shore.getRecipeOutput().isItemEqual(output)) {
if (shapelessOre.getRecipeOutput() == null || !shapelessOre.getRecipeOutput().isItemEqual(output)) {
continue;
}
list.add(input);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/binnie/genetics/gui/AnalystPageProduce.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ public Collection<ItemStack> getCrafting(ItemStack stack) {
}
}

if (iRecipe instanceof ShapelessOreRecipe shore) {
if (iRecipe instanceof ShapelessOreRecipe shapelessOre) {
boolean match = true;
for (final Object rec : shore.getInput()) {
for (final Object rec : shapelessOre.getInput()) {
if (rec != null && (!(rec instanceof ItemStack i) || !stack.isItemEqual(i))) {
match = false;
break;
Expand All @@ -126,7 +126,7 @@ public Collection<ItemStack> getCrafting(ItemStack stack) {
if (!match) {
continue;
}
products.add(shore.getRecipeOutput());
products.add(shapelessOre.getRecipeOutput());
}
}
return products;
Expand Down

0 comments on commit 9ff3409

Please sign in to comment.