mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 19:13:42 +01:00
Remove unnecessary code
- Remove block vertex color code - Remove experimentalRendering config - Move as much Item.Properties configuration to AllItems as possible
This commit is contained in:
parent
9c42988135
commit
3c71e8041b
14 changed files with 22 additions and 185 deletions
|
@ -27,10 +27,10 @@ boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equal
|
|||
// The project is named Flywheel-Forge, but sub-projects are named by folder.
|
||||
boolean inWorkspace = findProject(':Flywheel') != null
|
||||
|
||||
ext.buildnumber = 0
|
||||
project.buildnumber = System.getenv('BUILD_NUMBER') != null ? System.getenv('BUILD_NUMBER') : 'custom'
|
||||
ext.buildNumber = System.getenv('BUILD_NUMBER')
|
||||
if (buildNumber == null) buildNumber = 'custom'
|
||||
|
||||
version = "mc${minecraft_version}_v${mod_version}" + (dev && !buildnumber.equals('custom') ? "+${buildnumber}" : '')
|
||||
version = "mc${minecraft_version}_v${mod_version}" + (dev && !buildNumber.equals('custom') ? "+${buildNumber}" : '')
|
||||
group = 'com.simibubi.create'
|
||||
archivesBaseName = 'create'
|
||||
|
||||
|
|
|
@ -288,16 +288,17 @@ public class AllItems {
|
|||
|
||||
public static final ItemEntry<PotatoCannonItem> POTATO_CANNON =
|
||||
REGISTRATE.item("potato_cannon", PotatoCannonItem::new)
|
||||
.properties(p -> p.stacksTo(1))
|
||||
.model(AssetLookup.itemModelWithPartials())
|
||||
.register();
|
||||
|
||||
public static final ItemEntry<ExtendoGripItem> EXTENDO_GRIP = REGISTRATE.item("extendo_grip", ExtendoGripItem::new)
|
||||
.properties(p -> p.rarity(Rarity.UNCOMMON))
|
||||
.model(AssetLookup.itemModelWithPartials())
|
||||
.register();
|
||||
|
||||
public static final ItemEntry<SymmetryWandItem> WAND_OF_SYMMETRY =
|
||||
REGISTRATE.item("wand_of_symmetry", SymmetryWandItem::new)
|
||||
.properties(p -> p.stacksTo(1).rarity(Rarity.UNCOMMON))
|
||||
.model(AssetLookup.itemModelWithPartials())
|
||||
.register();
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -57,8 +56,7 @@ public class SymmetryWandItem extends Item {
|
|||
private static final String ENABLE = "enable";
|
||||
|
||||
public SymmetryWandItem(Properties properties) {
|
||||
super(properties.stacksTo(1)
|
||||
.rarity(Rarity.UNCOMMON));
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
|
@ -55,8 +54,6 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|||
|
||||
@EventBusSubscriber
|
||||
public class ExtendoGripItem extends Item {
|
||||
private static DamageSource lastActiveDamageSource;
|
||||
|
||||
public static final int MAX_DAMAGE = 200;
|
||||
|
||||
public static final AttributeModifier singleRangeAttributeModifier =
|
||||
|
@ -66,19 +63,19 @@ public class ExtendoGripItem extends Item {
|
|||
new AttributeModifier(UUID.fromString("8f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier", 5,
|
||||
AttributeModifier.Operation.ADDITION);
|
||||
|
||||
static Supplier<Multimap<Attribute, AttributeModifier>> rangeModifier = Suppliers.memoize(() ->
|
||||
private static final Supplier<Multimap<Attribute, AttributeModifier>> rangeModifier = Suppliers.memoize(() ->
|
||||
// Holding an ExtendoGrip
|
||||
ImmutableMultimap.of(ForgeMod.REACH_DISTANCE.get(), singleRangeAttributeModifier)
|
||||
);
|
||||
|
||||
static Supplier<Multimap<Attribute, AttributeModifier>> doubleRangeModifier = Suppliers.memoize(() ->
|
||||
private static final Supplier<Multimap<Attribute, AttributeModifier>> doubleRangeModifier = Suppliers.memoize(() ->
|
||||
// Holding two ExtendoGrips o.O
|
||||
ImmutableMultimap.of(ForgeMod.REACH_DISTANCE.get(), doubleRangeAttributeModifier)
|
||||
);
|
||||
|
||||
private static DamageSource lastActiveDamageSource;
|
||||
|
||||
public ExtendoGripItem(Properties properties) {
|
||||
super(properties.stacksTo(1)
|
||||
.rarity(Rarity.UNCOMMON));
|
||||
super(properties.defaultDurability(MAX_DAMAGE));
|
||||
}
|
||||
|
||||
public static final String EXTENDO_MARKER = "createExtendo";
|
||||
|
@ -194,10 +191,10 @@ public class ExtendoGripItem extends Item {
|
|||
findAndDamageExtendoGrip((Player) entity);
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public static void consumeDurabilityOnPlace(PlayerInteractEvent event) {
|
||||
// @SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
// public static void consumeDurabilityOnPlace(PlayerInteractEvent event) {
|
||||
// findAndDamageExtendoGrip(event.getPlayer());
|
||||
}
|
||||
// }
|
||||
|
||||
private static void findAndDamageExtendoGrip(Player player) {
|
||||
if (player == null)
|
||||
|
@ -236,16 +233,6 @@ public class ExtendoGripItem extends Item {
|
|||
return AllConfigs.SERVER.curiosities.maxExtendoGripActions.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeDepleted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return MAX_DAMAGE;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void bufferLivingAttackEvent(LivingAttackEvent event) {
|
||||
// Workaround for removed patch to get the attacking entity.
|
||||
|
|
|
@ -45,7 +45,7 @@ import net.minecraftforge.common.util.FakePlayer;
|
|||
public class SandPaperItem extends Item implements CustomUseEffectsItem {
|
||||
|
||||
public SandPaperItem(Properties properties) {
|
||||
super(properties.durability(8));
|
||||
super(properties.defaultDurability(8));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,7 +53,7 @@ public class PotatoCannonItem extends ProjectileWeaponItem {
|
|||
public static final int MAX_DAMAGE = 100;
|
||||
|
||||
public PotatoCannonItem(Properties properties) {
|
||||
super(properties);
|
||||
super(properties.defaultDurability(MAX_DAMAGE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,11 +81,6 @@ public class PotatoCannonItem extends ProjectileWeaponItem {
|
|||
return use(context.getLevel(), context.getPlayer(), context.getHand()).getResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit(ItemStack stack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBarVisible(ItemStack stack) {
|
||||
return BackTankUtil.isBarVisible(stack, maxUses());
|
||||
|
@ -105,20 +100,10 @@ public class PotatoCannonItem extends ProjectileWeaponItem {
|
|||
return AllConfigs.SERVER.curiosities.maxPotatoCannonShots.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeDepleted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isCannon(ItemStack stack) {
|
||||
return stack.getItem() instanceof PotatoCannonItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return MAX_DAMAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
|
@ -275,11 +260,6 @@ public class PotatoCannonItem extends ProjectileWeaponItem {
|
|||
.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantmentValue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEntitySwing(ItemStack stack, LivingEntity entity) {
|
||||
return true;
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package com.simibubi.create.content.palettes;
|
||||
|
||||
import com.simibubi.create.foundation.block.render.IBlockVertexColor;
|
||||
import com.simibubi.create.foundation.utility.Color;
|
||||
|
||||
public class ScoriaVertexColor implements IBlockVertexColor {
|
||||
|
||||
public static final ScoriaVertexColor INSTANCE = new ScoriaVertexColor();
|
||||
|
||||
@Override
|
||||
public int getColor(float x, float y, float z) {
|
||||
float x2 = (float) Math.floor(z + x - y * .5);
|
||||
float y2 = (float) Math.floor(y * 1.5 + x * .5 - z);
|
||||
float z2 = (float) Math.floor(y - z * .5 - x);
|
||||
|
||||
Color color = new Color(0x448888);
|
||||
if (x2 % 2 == 0)
|
||||
color.modifyValue(v -> v | 0x0011ff);
|
||||
if (z2 % 2 == 0)
|
||||
color.modifyValue(v -> v | 0x888888);
|
||||
|
||||
color.mixWith(Color.rainbowColor((int) (x + y + z) * 170), .4f);
|
||||
|
||||
if ((x2 % 4 == 0) || (y2 % 4 == 0))
|
||||
color.mixWith(Color.WHITE, .8f);
|
||||
|
||||
return color.getRGB() & 0x00_ffffff;
|
||||
}
|
||||
|
||||
}
|
|
@ -56,7 +56,7 @@ public class SchematicItem extends Item {
|
|||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public SchematicItem(Properties properties) {
|
||||
super(properties.stacksTo(1));
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public static ItemStack create(String schematic, String owner) {
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
package com.simibubi.create.foundation.block.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
public class ColoredVertexModel extends BakedModelWrapper<BakedModel> {
|
||||
|
||||
private static final ModelProperty<BlockPos> POSITION_PROPERTY = new ModelProperty<>();
|
||||
private IBlockVertexColor color;
|
||||
|
||||
public ColoredVertexModel(BakedModel originalModel, IBlockVertexColor color) {
|
||||
super(originalModel);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData) {
|
||||
return new ModelDataMap.Builder().withInitial(POSITION_PROPERTY, pos).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(BlockState state, Direction side, Random rand, IModelData extraData) {
|
||||
List<BakedQuad> quads = super.getQuads(state, side, rand, extraData);
|
||||
if (quads.isEmpty())
|
||||
return quads;
|
||||
if (!extraData.hasProperty(POSITION_PROPERTY))
|
||||
return quads;
|
||||
BlockPos data = extraData.getData(POSITION_PROPERTY);
|
||||
quads = new ArrayList<>(quads);
|
||||
|
||||
// Optifine might've rejigged vertex data
|
||||
VertexFormat format = DefaultVertexFormat.BLOCK;
|
||||
int colorIndex = 0;
|
||||
for (int elementId = 0; elementId < format.getElements().size(); elementId++) {
|
||||
VertexFormatElement element = format.getElements().get(elementId);
|
||||
if (element.getUsage() == VertexFormatElement.Usage.COLOR)
|
||||
colorIndex = elementId;
|
||||
}
|
||||
int colorOffset = format.getOffset(colorIndex) / 4;
|
||||
|
||||
for (int i = 0; i < quads.size(); i++) {
|
||||
BakedQuad quad = quads.get(i);
|
||||
|
||||
BakedQuad newQuad = QuadHelper.clone(quad);
|
||||
int[] vertexData = newQuad.getVertices();
|
||||
|
||||
for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) {
|
||||
float x = Float.intBitsToFloat(vertexData[vertex]);
|
||||
float y = Float.intBitsToFloat(vertexData[vertex + 1]);
|
||||
float z = Float.intBitsToFloat(vertexData[vertex + 2]);
|
||||
int color = this.color.getColor(x + data.getX(), y + data.getY(), z + data.getZ());
|
||||
vertexData[vertex + colorOffset] = color;
|
||||
}
|
||||
|
||||
quads.set(i, newQuad);
|
||||
}
|
||||
return quads;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package com.simibubi.create.foundation.block.render;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IBlockVertexColor {
|
||||
|
||||
public int getColor(float x, float y, float z);
|
||||
|
||||
}
|
|
@ -19,8 +19,6 @@ public class CClient extends ConfigBase {
|
|||
public final ConfigFloat filterItemRenderDistance = f(10f, 1, "filterItemRenderDistance", Comments.filterItemRenderDistance);
|
||||
public final ConfigBool rainbowDebug = b(true, "enableRainbowDebug",
|
||||
Comments.rainbowDebug);
|
||||
public final ConfigBool experimentalRendering = b(true, "experimentalRendering",
|
||||
Comments.experimentalRendering);
|
||||
public final ConfigInt maxContraptionLightVolume = i(16384, 0, Integer.MAX_VALUE, "maximumContraptionLightVolume",
|
||||
Comments.maxContraptionLightVolume);
|
||||
// no group
|
||||
|
@ -95,7 +93,6 @@ public class CClient extends ConfigBase {
|
|||
"Maximum Distance to the player at which items in Blocks' filter slots will be displayed"
|
||||
};
|
||||
static String rainbowDebug = "Show colourful debug information while the F3-Menu is open.";
|
||||
static String experimentalRendering = "Use modern OpenGL features to drastically increase performance.";
|
||||
static String maxContraptionLightVolume = "The maximum amount of blocks for which to try and calculate dynamic contraption lighting. Decrease if large contraption cause too much lag";
|
||||
static String[] mainMenuConfigButtonRow = new String[]{
|
||||
"Choose the menu row that the Create config button appears on in the main menu",
|
||||
|
|
|
@ -18,8 +18,6 @@ import com.simibubi.create.content.contraptions.fluids.VirtualFluid;
|
|||
import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity;
|
||||
import com.simibubi.create.foundation.block.connected.CTModel;
|
||||
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour;
|
||||
import com.simibubi.create.foundation.block.render.ColoredVertexModel;
|
||||
import com.simibubi.create.foundation.block.render.IBlockVertexColor;
|
||||
import com.tterrag.registrate.AbstractRegistrate;
|
||||
import com.tterrag.registrate.builders.BlockBuilder;
|
||||
import com.tterrag.registrate.builders.BlockEntityBuilder.BlockEntityFactory;
|
||||
|
@ -198,10 +196,6 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
|||
return entry -> onClient(() -> () -> registerCasingConnectivity(entry, consumer));
|
||||
}
|
||||
|
||||
public static <T extends Block> NonNullConsumer<? super T> blockVertexColors(IBlockVertexColor colorFunc) {
|
||||
return entry -> onClient(() -> () -> registerBlockVertexColor(entry, colorFunc));
|
||||
}
|
||||
|
||||
public static <T extends Block> NonNullConsumer<? super T> blockModel(
|
||||
Supplier<NonNullFunction<BakedModel, ? extends BakedModel>> func) {
|
||||
return entry -> onClient(() -> () -> registerBlockModel(entry, func));
|
||||
|
@ -229,12 +223,6 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
|
|||
consumer.accept(entry, CreateClient.CASING_CONNECTIVITY);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void registerBlockVertexColor(Block entry, IBlockVertexColor colorFunc) {
|
||||
CreateClient.MODEL_SWAPPER.getCustomBlockModels()
|
||||
.register(entry.delegate, model -> new ColoredVertexModel(model, colorFunc));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void registerBlockModel(Block entry,
|
||||
Supplier<NonNullFunction<BakedModel, ? extends BakedModel>> func) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.client.resources.model.ModelBakery;
|
|||
|
||||
public class SuperRenderTypeBuffer implements MultiBufferSource {
|
||||
|
||||
private static final SuperRenderTypeBuffer INSTANCE = new SuperRenderTypeBuffer();;
|
||||
private static final SuperRenderTypeBuffer INSTANCE = new SuperRenderTypeBuffer();
|
||||
|
||||
public static SuperRenderTypeBuffer getInstance() {
|
||||
return INSTANCE;
|
||||
|
|
|
@ -10,11 +10,11 @@ import net.minecraft.world.level.LevelAccessor;
|
|||
public class AnimationTickHolder {
|
||||
|
||||
private static int ticks;
|
||||
private static int paused_ticks;
|
||||
private static int pausedTicks;
|
||||
|
||||
public static void reset() {
|
||||
ticks = 0;
|
||||
paused_ticks = 0;
|
||||
pausedTicks = 0;
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
|
@ -22,7 +22,7 @@ public class AnimationTickHolder {
|
|||
.isPaused()) {
|
||||
ticks = (ticks + 1) % 1_728_000; // wrap around every 24 hours so we maintain enough floating point precision
|
||||
} else {
|
||||
paused_ticks = (paused_ticks + 1) % 1_728_000;
|
||||
pausedTicks = (pausedTicks + 1) % 1_728_000;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class AnimationTickHolder {
|
|||
}
|
||||
|
||||
public static int getTicks(boolean includePaused) {
|
||||
return includePaused ? ticks + paused_ticks : ticks;
|
||||
return includePaused ? ticks + pausedTicks : ticks;
|
||||
}
|
||||
|
||||
public static float getRenderTime() {
|
||||
|
|
Loading…
Reference in a new issue